# @summary A short summary of the purpose of this class
#
# A description of what this class does
#
# @example
#   include csns::slurm::config
class csns::slurm::config {
	
file { '/csns_workspace':
		ensure => link,
		target => '/dg_workfs',
     }->
	
#exec {'echo6':
#     		unless   => 'cat /etc/fstab |grep "10.1.231.22:/csns_workspace"',
#    		command  => 'echo "10.1.231.22:/csns_workspace     /csns_workspace   glusterfs     defaults,acl    0   0" >> /etc/fstab',
#   		path => "/usr/bin:/bin",
#	}->	
	
#exec {'mount':
#     	 	command =>'mount -a',
#      		subscribe => Exec["echo6"],
#    		path =>"/usr/bin:/bin",
#   		refreshonly => true,
#		require => File['/csns_workspace'],
#     }	
	
group{'munge':
      ensure => present,
      name => 'munge',
      gid => '501',
      require => Class['csns::slurm::install'],
     }

 group{'slurm':
      ensure => present,
      name => 'slurm',
      gid => '502',
      require => Class['csns::slurm::install'],
     }

 user{'munge':
      ensure => present,
      name => 'munge',
      uid => '501',
      require => Group['munge'],
      groups => 'munge',
      shell => '/sbin/nologin',
     }

 user{'slurm':
      ensure => present,
      name => 'slurm',
      uid => '502',
      require => Group['slurm'],
      groups => 'slurm',
      shell => '/sbin/nologin',
     }

 file{'/etc/munge':
     ensure => directory,
     mode => '0700',
     owner => 'munge',
     group => 'munge',
     require => Class['csns::slurm::install'],
     }

 file{'/var/lib/munge':
     ensure => directory,
     mode => '0711',
     owner => 'munge',
     group => 'munge',
     require => Class['csns::slurm::install'],
     }

 file{'/var/log/munge':
     ensure => directory,
     mode => '0700',
     owner => 'munge',
     group => 'munge',
     require => Class['csns::slurm::install'],
     }

file{'/var/run/munge':
     ensure => directory,
     mode => '0755',
     owner => 'munge',
     group => 'munge',
     require => Class['csns::slurm::install'],
     }

 file{'/etc/munge/munge.key':
     source => "puppet://$puppetserver/modules/${module_name}/slurm/munge.key",
     ensure => present,
     mode => '0600',
     owner => 'munge',
     group => 'munge',
     require => Class['csns::slurm::install'],
     notify => Class['csns::slurm::service'],
     }


 file{'/etc/slurm':
	ensure => link,
	target => '/hpcfs/slurm1_share/etc/slurm',
	force => true,
	}

# file{'/etc/slurm/slurm.conf':
#     source => "puppet://$puppetserver/modules/${module_name}/slurm/slurm.conf",
#     ensure => present,
#     mode => '0644',
#     owner => 'slurm',
#     group => 'slurm',
#     require => Class['csns::slurm::install'],
#     notify => Class['csns::slurm::service'],
#}


# file{'/etc/slurm/slurmdbd.conf':
#     source => "puppet://$puppetserver/modules/${module_name}/slurm/slurmdbd.conf",
#     ensure => present,
#     mode => '0600',
#     owner => 'slurm',
#     group => 'slurm',
#     require => Class['csns::slurm::install'],
#}

# file{'/etc/slurm/cgroup.conf':
#     source => "puppet://$puppetserver/modules/${module_name}/slurm/cgroup.conf",
#     ensure => present,
#     mode => '0644',
#     owner => 'slurm',
#     group => 'slurm',
#     require => Class['csns::slurm::install'],
#     notify => Class['csns::slurm::service'],
#}

# file{'/etc/slurm/gres.conf':
#     source => "puppet://$puppetserver/modules/${module_name}/slurm/gres.conf",
#     ensure => present,
#     mode => '0644',
#     owner => 'slurm',
#     group => 'slurm',
#     require => Class['csns::slurm::install'],
#     notify => Class['csns::slurm::service'],
#}

 case $hostname {
      /.*slurm.*?(?=\b)/,'mn':{
#   file{'/var/log/slurm':
#       ensure => directory,
#        owner => 'slurm',
#        group => 'slurm',
#        mode => '0755',
       

   file{'/var/log/slurm/slurmctld.log':
        ensure => present,
        owner => 'slurm',
        group => 'slurm',
        mode => '0666',
       }

    file{'/var/log/slurm/state/':
        ensure => directory,
        owner => 'slurm',
        group => 'slurm',
        mode => '0755',
       }

 /*  file{'/var/spool/slurmctld':
       ensure => directory,
        owner => 'slurm',
        group => 'slurm',
        mode => '0755',
       }
*/
#   file{'/csns_workspace/users/slurm/slurmctld':
#      ensure => directory,
#        owner => 'slurm',
#        group => 'slurm',
#        mode => '0755',
#       }

}	
}

file{'/var/log/slurm':
        ensure => directory,
        owner => 'slurm',
        group => 'slurm',
        mode => '0755',
       }

   file{'/var/log/slurm/slurmd.log':
       ensure => present,
        owner => 'slurm',
        group => 'slurm',
        mode => '0644',
       }

   file{'/var/spool/slurmd':
        ensure => directory,
        owner => 'slurm',
        group => 'slurm',
        mode => '0755',
       }

}
